 {{include file="../tools/jquery_validator2.htm"}}
 {{include file="../tools/upload.htm"}} 

<div class="userbox">
  <h2>创建小店</h2>
  <form name="category" id="category" method="post">
    <div class="left userstore">
      <table>
        <tr>
          <td colspan="2" class="nameorange" >小店起名</td>
        </tr>
        <tr>
          <td colspan="2" class="colororange">恭喜通过了验证</td>
        </tr>
        <tr>
          <td width="172">你的小店店名是什么：</td>
          <td width="350"><input type="text"  name="cat_name"  value="{{$cat.cat_name}}"/></td>
        </tr>
        <tr>
          <td   >再上传几张店内实景照片：</td>
          <td class="white_space ts4 paddbottom">
          <span class="ui-state-highlight ui-corner-all box"> 请上传宽高比 >= 500 X 500 的图片</span>
          
        {{if $cat.imgs}}
        {{foreach from=$cat.imgs item=list key=key}}
   
        {{$default[$key]['url']=$list}}
     
        {{/foreach}}
        {{$default=json_encode($default)}}
        <div id="img_default" class="none">{{$default}}</div>
       {{/if}}
           <div id="img"> </div>
          <div id="img_res">
       
          </div>
          <input type="text" value="{{$cat.img}}" name="img" id="imgs" class="size0"/>
          
           </td>
            
        </tr>
      </table>
      <div class="icobtn">
      	<input type="hidden"  name="c_id" value="{{$c_id}}"/>
        <input class="next" type="button"  onclick="steps()"/>
      </div>
    </div>
  </form>
  {{include file="./user_act_right.htm"}} 
  <!--right end--> 
  
</div>
<script>

  $(function(){
	  var cat_id = new Number('{{$user_info.cat_id}}');
	if(cat_id>0 && '{{$c_id}}'=='0')
	{
		alert('您已经创建或加入了小店，请回到自己的小店!');	
		location.href='category.php?cat_id={{$user_info.cat_id}}';
	}
	  
	var swf = swfUpload({
					   size:10,
					   limit:10,
					   type:'*.jpg;*.png;*.gif',
					   button_id:'img',
					   index:0,   //第几个实例
					   set_input:true, //是否将文件信息写到input中（json）
					   data_type:'text'
				   });
		
		
	 $('#category').validate(
	  {
	   
	 
	   rules: {
		cat_name: {
		  minlength: 2,
		  required: true
		
		},
		img: {
		  minlength: 2,
		 required: true
		
		}
	  },
	
	  messages: {   
		   cat_name: {       
			   required: "还未填写店名",   
			   
			   minlength: "小店名称必须大于2个字符"       
		   },   
		   img:{   
			   required: "请上传小店图片！" 
			  
		   }
   		}
	 });
		 
  })
  
  function steps(idx){
	
	
	  if( $('#category').valid())
	  {
	 	$('#category').submit();
	  }
  }
 
  </script>